package net.piggy.spring;

import net.piggy.server.NettyServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

@Component
public class InitLoadRemoteMethod implements ApplicationListener<ContextRefreshedEvent> {
    @Value("${api-application-sdk.systemAddress}")
    private String address;

    @Override
    public void onApplicationEvent(@NonNull ContextRefreshedEvent contextRefreshedEvent) {

        new Thread(() -> NettyServer.start(address)).start();
    }
}
